<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/laydate/laydate.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff;width: 100%;">
    <!-- header -->
    <div class="header">
        <div id="backBtn" class="head-back">
            <a onclick="balckData()" href="javascript:void(0);" tapmode class="back-btn"></a>
        </div>
        <div class="head-title">
            <h6>活动地点</h6>
        </div>
    </div>
	
    <!-- header end -->
</div>
<div class="map-section" style="width: 100%;">

</div>


</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    apiready = function () {

        setFixStatusBar(); //设置状态栏

        keybackListener()
        chooseMap();
    };
	function searchaddres(){
		var lat =api.pageParam.lat;
		var lon =api.pageParam.log;
		var aMap = api.require('aMap');
		aMap.addAnnotations({
		    annotations: [{
		        id: 1,
		        lon: lon,
		        lat: lat
		    }],
            icons: ['widget://icon/location.png'],
            w: 80,
            h: 80,
		    draggable: true,
		    timeInterval: 2.0
		}, function(ret) {
		    if (ret.eventType == 'click') {
		       // alert(ret.id);

                $(".LoadingGif").remove();
		    }
		});
		aMap.setCenter({
		    coords: {
		        lon: lon,
		        lat: lat
		    },
		    animation: false
		});
		
	}
	//返回
	function balckData(){
		comeBack();
		
	}
	

    function chooseMap() {
        if(api.systemType == 'ios'){
            var topH = $("#header").outerHeight(true) + 25;
        }else {
            var topH = $("#header").outerHeight(true) + 25;
        }
        var hh = $(window).height() - topH;
        $(".map-section").height(hh);
        var ww = $(".map-section").width();

        var html = '<div class="LoadingGif">' +
            '           <div class="gif"></div>' +
            '       </div>';
        $("body").append(html);

		var aMapLBS = api.require('aMapLBS');
		aMapLBS.configManager({
		    accuracy: 'hundredMeters',
		    filter: 1
		}, function(ret, err) {
		    if (ret.status) {
		        //alert('定位管理器初始化成功！');
				aMapLBS.startLocation(function(ret, err) {
					//alert(JSON.stringify(ret));
				    if (ret.status) {
						
				       
					   console.log(JSON.stringify(ret))
					   console.log(ret.lon)
						var aMap = api.require('aMap');
						
						aMap.open({
						    rect: {
						        x: 0,
						        y: topH,
						        w: ww,
						        h: hh
						    },
						    showUserLocation: true,
						    zoomLevel: 11,
						    center: {
						        lon:ret.lon,
						        lat:ret.lat
						    },
						    fixed: true
						}, function(ret, err) {
						    if (ret.status) {
								var aMapLBS = api.require('aMapLBS');
								aMapLBS.stopUpdatingLocation();
						        console.log(JSON.stringify(ret));
								searchaddres();
						        
						    } else {
						        console.log(JSON.stringify(err));
						    }
						});
				    }
				});
		    }
		});

        
    }



</script>
